/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv3.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

import org.taobao.ibatiside.model.mapperv3.Choose;
import org.taobao.ibatiside.model.mapperv3.CommonNestedStatement;
import org.taobao.ibatiside.model.mapperv3.Foreach;
import org.taobao.ibatiside.model.mapperv3.If;
import org.taobao.ibatiside.model.mapperv3.Include;
import org.taobao.ibatiside.model.mapperv3.Mapperv3Package;
import org.taobao.ibatiside.model.mapperv3.Set;
import org.taobao.ibatiside.model.mapperv3.Trim;
import org.taobao.ibatiside.model.mapperv3.Where;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Common Nested Statement</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getMixed <em>Mixed</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getTgNestedCondition <em>Tg Nested Condition</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getInclude <em>Include</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getTrim <em>Trim</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getWhere <em>Where</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getSet <em>Set</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getForeach <em>Foreach</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getChoose <em>Choose</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CommonNestedStatementImpl#getIf <em>If</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class CommonNestedStatementImpl extends EObjectImpl implements CommonNestedStatement {
	/**
	 * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMixed()
	 * @generated
	 * @ordered
	 */
	protected FeatureMap mixed;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CommonNestedStatementImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv3Package.Literals.COMMON_NESTED_STATEMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getMixed() {
		if (mixed == null) {
			mixed = new BasicFeatureMap(this, Mapperv3Package.COMMON_NESTED_STATEMENT__MIXED);
		}
		return mixed;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getTgNestedCondition() {
		return (FeatureMap)getMixed().<FeatureMap.Entry>list(Mapperv3Package.Literals.COMMON_NESTED_STATEMENT__TG_NESTED_CONDITION);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Include> getInclude() {
		return getTgNestedCondition().list(Mapperv3Package.Literals.COMMON_NESTED_STATEMENT__INCLUDE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Trim> getTrim() {
		return getTgNestedCondition().list(Mapperv3Package.Literals.COMMON_NESTED_STATEMENT__TRIM);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Where> getWhere() {
		return getTgNestedCondition().list(Mapperv3Package.Literals.COMMON_NESTED_STATEMENT__WHERE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Set> getSet() {
		return getTgNestedCondition().list(Mapperv3Package.Literals.COMMON_NESTED_STATEMENT__SET);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Foreach> getForeach() {
		return getTgNestedCondition().list(Mapperv3Package.Literals.COMMON_NESTED_STATEMENT__FOREACH);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Choose> getChoose() {
		return getTgNestedCondition().list(Mapperv3Package.Literals.COMMON_NESTED_STATEMENT__CHOOSE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<If> getIf() {
		return getTgNestedCondition().list(Mapperv3Package.Literals.COMMON_NESTED_STATEMENT__IF);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Mapperv3Package.COMMON_NESTED_STATEMENT__MIXED:
				return ((InternalEList<?>)getMixed()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TG_NESTED_CONDITION:
				return ((InternalEList<?>)getTgNestedCondition()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.COMMON_NESTED_STATEMENT__INCLUDE:
				return ((InternalEList<?>)getInclude()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TRIM:
				return ((InternalEList<?>)getTrim()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.COMMON_NESTED_STATEMENT__WHERE:
				return ((InternalEList<?>)getWhere()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.COMMON_NESTED_STATEMENT__SET:
				return ((InternalEList<?>)getSet()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.COMMON_NESTED_STATEMENT__FOREACH:
				return ((InternalEList<?>)getForeach()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.COMMON_NESTED_STATEMENT__CHOOSE:
				return ((InternalEList<?>)getChoose()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.COMMON_NESTED_STATEMENT__IF:
				return ((InternalEList<?>)getIf()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv3Package.COMMON_NESTED_STATEMENT__MIXED:
				if (coreType) return getMixed();
				return ((FeatureMap.Internal)getMixed()).getWrapper();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TG_NESTED_CONDITION:
				if (coreType) return getTgNestedCondition();
				return ((FeatureMap.Internal)getTgNestedCondition()).getWrapper();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__INCLUDE:
				return getInclude();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TRIM:
				return getTrim();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__WHERE:
				return getWhere();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__SET:
				return getSet();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__FOREACH:
				return getForeach();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__CHOOSE:
				return getChoose();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__IF:
				return getIf();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv3Package.COMMON_NESTED_STATEMENT__MIXED:
				((FeatureMap.Internal)getMixed()).set(newValue);
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TG_NESTED_CONDITION:
				((FeatureMap.Internal)getTgNestedCondition()).set(newValue);
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__INCLUDE:
				getInclude().clear();
				getInclude().addAll((Collection<? extends Include>)newValue);
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TRIM:
				getTrim().clear();
				getTrim().addAll((Collection<? extends Trim>)newValue);
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__WHERE:
				getWhere().clear();
				getWhere().addAll((Collection<? extends Where>)newValue);
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__SET:
				getSet().clear();
				getSet().addAll((Collection<? extends Set>)newValue);
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__FOREACH:
				getForeach().clear();
				getForeach().addAll((Collection<? extends Foreach>)newValue);
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__CHOOSE:
				getChoose().clear();
				getChoose().addAll((Collection<? extends Choose>)newValue);
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__IF:
				getIf().clear();
				getIf().addAll((Collection<? extends If>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv3Package.COMMON_NESTED_STATEMENT__MIXED:
				getMixed().clear();
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TG_NESTED_CONDITION:
				getTgNestedCondition().clear();
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__INCLUDE:
				getInclude().clear();
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TRIM:
				getTrim().clear();
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__WHERE:
				getWhere().clear();
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__SET:
				getSet().clear();
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__FOREACH:
				getForeach().clear();
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__CHOOSE:
				getChoose().clear();
				return;
			case Mapperv3Package.COMMON_NESTED_STATEMENT__IF:
				getIf().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv3Package.COMMON_NESTED_STATEMENT__MIXED:
				return mixed != null && !mixed.isEmpty();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TG_NESTED_CONDITION:
				return !getTgNestedCondition().isEmpty();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__INCLUDE:
				return !getInclude().isEmpty();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__TRIM:
				return !getTrim().isEmpty();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__WHERE:
				return !getWhere().isEmpty();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__SET:
				return !getSet().isEmpty();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__FOREACH:
				return !getForeach().isEmpty();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__CHOOSE:
				return !getChoose().isEmpty();
			case Mapperv3Package.COMMON_NESTED_STATEMENT__IF:
				return !getIf().isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (mixed: ");
		result.append(mixed);
		result.append(')');
		return result.toString();
	}

} //CommonNestedStatementImpl
